package com.sl.au.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.sl.au.entity.ViewForEventRegisterTask;

public interface ViewForEventRegisterTaskRepository extends JpaRepository<ViewForEventRegisterTask, String>{

	@Query("select a from ViewForEventRegisterTask a where a.eventTaskState=?1 and a.registerEventState=?1 and a.eventTaskUser=?2")
	Page<ViewForEventRegisterTask> getByStateAndOperateUser(String state,String user, Pageable pageable);
	
	@Query("select a from ViewForEventRegisterTask a where  a.eventTaskUser=?1")
	Page<ViewForEventRegisterTask> getByOperateUser(String user, Pageable pageable);
	
	@Query("select a from ViewForEventRegisterTask a where a.eventTaskState=?1 and a.registerEventState=?1")
	Page<ViewForEventRegisterTask> getByState(String state, Pageable pageable);
	
	@Query("select a from ViewForEventRegisterTask a where a.eventTaskState=?1 and a.registerEventState=?1 and(a.registerEventContent like %?2%)")
	Page<ViewForEventRegisterTask> getByStateWithKey(String state, String key,Pageable pageable);
	
	@Query("select a from ViewForEventRegisterTask a where a.eventTaskState=?1 and a.registerEventState=?1 and a.eventTaskUser=?2 and (a.registerEventContent like %?3%)")
	Page<ViewForEventRegisterTask> getByStateAndOperateUserWithKey(String state,String user,String key, Pageable pageable);
	
	@Query("select a from ViewForEventRegisterTask a where  a.eventTaskUser=?1 and (a.registerEventContent like %?3%)")
	Page<ViewForEventRegisterTask> getByOperateUserWithKey(String user, String key,Pageable pageable);
	
	@Query("select a from ViewForEventRegisterTask a where a.registerEventContent like %?3%")
	Page<ViewForEventRegisterTask> getByKey(String key,Pageable pageable);
	
	@Query("select a from ViewForEventRegisterTask a where a.eventTaskState=?1 and a.id = ?2 order by a.eventTaskTime desc")
	ViewForEventRegisterTask getByState(String opt,String id);
}
